package cn.iocoder.yudao.module.erp.dal.mysql.business.group.suppliergroup;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.erp.controller.admin.business.group.suppliergroup.vo.SupplierGroupPageReqVO;
import cn.iocoder.yudao.module.erp.dal.dataobject.business.group.suppliergroup.SupplierGroupDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 供应商分组 Mapper
 *
 * @author maxuxu
 */
@Mapper
public interface SupplierGroupMapper extends BaseMapperX<SupplierGroupDO> {

    default PageResult<SupplierGroupDO> selectPage(SupplierGroupPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<SupplierGroupDO>()
                .likeIfPresent(SupplierGroupDO::getName, reqVO.getName())
                .betweenIfPresent(SupplierGroupDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(SupplierGroupDO::getUpdater, reqVO.getUpdater())
                .orderByDesc(SupplierGroupDO::getId));
    }

    default SupplierGroupDO selectByName(String name) {
        return selectOne(SupplierGroupDO::getName,name);
    }
}